package com.qingzhuge.member.controller;

import com.qingzhuge.controller.base.AbstractController;
import com.qingzhuge.dto.response.ResponseBodyDto;
import com.qingzhuge.member.dto.request.SysImageTextResponseDto;
import com.qingzhuge.member.entity.SysImageText;
import com.qingzhuge.member.service.IMalImageTextService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static com.qingzhuge.common.Constants.Controller.PATH_BY_ID;

/**
 * @author zero.xiao
 */
@Api(tags = "A图文信息")
@RestController
@RequestMapping("/api/open/imagetext")
public class ApiImageTextController extends AbstractController {

    @Resource
    private IMalImageTextService imageTextService;

    @ApiOperation(value = "详情")
    @GetMapping(PATH_BY_ID)
    public ResponseEntity<ResponseBodyDto<SysImageTextResponseDto>> get(@PathVariable("id") Long id) {
        if (id == null) {
            return returnFailed("查询不能为空");
        }
        SysImageText details = imageTextService.getDetails(id, true);
        SysImageTextResponseDto responseDto = imageTextService.bean2Dto(details, SysImageTextResponseDto.class);
        return returnSuccess(responseDto);
    }
}
